<%@ page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@ page
	import="java.io.*, java.sql.*, java.util.*, java.text.*, napal.*, util.*, napal.*"%>
<%@ page import="org.apache.ibatis.*"%>
<%@ page import="java.util.Date"%>
<%
	request.setCharacterEncoding("utf-8");
	String cmd = request.getParameter("cmd");
	String dbname =request.getParameter("dbname");
	String boardName = request.getParameter("boardName");
	
	

	if(request.getParameter("dbsubject")!=null
			&& request.getParameter("dbmemo")!=null){
		String select01 = request.getParameter("select01");
		String dbsubject = request.getParameter("dbsubject");
		String dbmemo = request.getParameter("dbmemo");
	
		if ("등록".equals(cmd)) {
			if(select01.equals("말머리를 선택하세요.")){%>
				<script language=javascript>
							self.window.alert("말머리를 선택해주세요.");
							//location.href="BoardWrite.jsp";
						</script>
			<% }
			else if ((String)session.getAttribute("managerID")!=null) {
				 RentalHome.insertBoardManager(dbname, select01, dbsubject, dbmemo,boardName);%>
						<script language=javascript>
							self.window.alert("입력한 글을 저장하였습니다.");
							location.href="BoardList.jsp";
						</script>
					<% }
				else if((String)session.getAttribute("userID")!=null){
					RentalHome.insertBoardUser(dbname, select01, dbsubject, dbmemo,boardName);%>
						<script language=javascript>
							self.window.alert("입력한 글을 저장하였습니다.");
							location.href="BoardList.jsp";
						</script>
					<% 
				}
		}
	}


%>

<%@ include file="./Header.jsp"%>
			</td>
		</TR>
		<TR HEIGHT="100">
		<td>
		
		
		
		<script language="javascript">
	function writeCheck()
	{
		var form = document.writeform;
		
		if( !form.dbname.value )
		{
			alert( "이름을 적어주세요" );
			form.dbname.focus();
			return;
		}

		if( !form.dbsubject.value )
		{
			alert( "제목을 적어주세요" );
			form.dbsubject.focus();
			return;
		}

		if( !form.dbmemo.value )
		{
			alert( "내용을 적어주세요" );
			form.dbmemo.focus();
			return;
		}
		form.submit();
	}
</script> 
	<form onsubmit="return confirm('해당 게시글을 입력하시겠습니까?'); ">
<p align="center">
<table width=80% border=1 cellspacing=0 cellpadding=5 class="table">

		<tr>
			<td width=20%><b><p align="right">이름</p></b></td>
			<td width=80%><% if ((String)session.getAttribute("managerID")!=null) { %>
<input type=hidden name=dbname class="input-block-level" size=200  maxlength=50 value =<%=(String)session.getAttribute("managerID") %>>
<input type=text name=boardName value=<%=(String)session.getAttribute("managerRank") %>>
<%  }
	else if((String)session.getAttribute("userID")!=null){ %>
<input type=hidden name=dbname class="input-block-level" size=200  maxlength=50 value =<%=(String)session.getAttribute("userID") %>>
<input type=text name=boardName value=<%=(String)session.getAttribute("userName") %>>
	<%  } %>
	</td>
		</tr>
					<tr><td><b><p align="right">말머리</p></b></td>
			<td>
		<select name="select01">
		<option>말머리를 선택하세요.</option>
			<%if((String)session.getAttribute("userID")==null){ %><OPTION VALUE="공지사항">공지사항</OPTION><% }%>
			<OPTION VALUE="질문">질문</option>
		</SELECT>
	
	
			</td>
		</tr>
			<tr><td><b><p align="right">제목</p></b></td>
			<td><input type=text class="input-block-level" name=dbsubject size=200  maxlength=50></td>
		</tr>

			<tr><td><b><p align="right">내용</p></b></td>
			<td><textarea name=dbmemo cols=50 rows=20 class="input-block-level"></textarea></td>
		</tr>
	
</table>
		
		</p>
<p align="right">
<table cellspacing = 0 cellpadding = 0 border = 0 width=80%>
	<tr>
		<td><input
			name="cmd" class="btn btn-inverse" type=submit value="등록">
			</form>
		</td>
	</tr>
</table>
</p>

		
		
		
		
		
			
	</TD>
</TR>



<TR HEIGHT="100">
<TD><%@ include file="./bottom.jsp"%></TD> 
</TR>
</TABLE>
</body>
</html>